#------------------------------------------------------------------------------
EXE  = funcHdr

SRC += funcHdr.c  hdrOutput.c
SRC += dir.c  C_funcs.c

LIB = 

#------------------------------------------------------------------------------
COMPILE = gcc -c -Wall
DEBUG   = gcc -c -g -Wall
CC      = $(COMPILE)

GETDEPS = gcc -M
LINK    = gcc -o
MAKE    = make
DEL     = rm -f
COPY    = cp

OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)

#------------------------------------------------------------------------------
run: $(EXE)
	[ -x $(EXE) ] && ./$(EXE) . _test*.c

#------------------------------------------------------------------------------
exe all: $(EXE) Makefile

#------------------------------------------------------------------------------
.PHONY: clean
clean:
	$(DEL) $(EXE) $(OBJ) $(DEP)

$(EXE): $(OBJ) $(DEP)
	$(LINK) $(EXE) $(OBJ) $(LIB)

#------------------------------------------------------------------------------
%.o: %.d
	@echo :-----[ COMPILE: $@ ]-----:
	$(CC) -o $@ $(<:.d=.c)

#------------------------------------------------------------------------------
%.d: %.c
	@echo :-----[ DEPS: $@ ]-----:
	@$(DEL) $@
	$(GETDEPS) $< > $@.~tmp
	@sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.~tmp > $@
	@$(RM) $@.~tmp

#------------------------------------------------------------------------------
ifneq (,$(DEP))
  include $(DEP)
endif

